



<template>
 
    
   
  <el-form :inline="true" >
      <!-- 一级分类 -->
    <el-form-item label="一级分类">
      <el-select v-model="category1Id" placeholder="请选择">
        <el-option   :label="c1.name"  v-for="c1 in categoryStore.category1List" :key="c1.id"    :value="c1.id" />
      
      </el-select>
    </el-form-item>

<!-- 二级分类 -->
  <el-form-item label="二级分类">
      <el-select v-model="category2Id" placeholder="请选择">
        <el-option :label="c2.name" v-for="c2 in categoryStore.category2List" :key="c2.id" :value="c2.id" />
       
      </el-select>
    </el-form-item>

<!-- 三级分类 -->

  <el-form-item label="三级分类">
      <el-select v-model="categoryStore.category3Id" placeholder="请选择">
       <el-option :label="c3.name" v-for="c3 in categoryStore.category3List" :key="c3.id" :value="c3.id" />
       
      </el-select>
    </el-form-item>
  </el-form>

</template>
 

<script lang="ts">
import { computed, onMounted } from 'vue';
import {useCategoryListStore} from'@/stores/categoryList'
export default {
  name: 'CateqorySelector'
}
</script>


<script lang="ts" setup>
import { reactive } from 'vue'
import { ref } from 'vue'
//解构菠萝
const categoryStore=useCategoryListStore()

const formInline = reactive({
  user: '',
  region: '',
})



//计算简写一二三级ID

const category1Id = computed<number>({
  get() {
    return categoryStore.category1Id as number
  },
  async set(val) {
   categoryStore.reqattrInfoListDate2(val)
  }
})

const category2Id = computed<number>({
  get() {
    return categoryStore.category2Id as number
  },
  set(val) {
    categoryStore.reqattrInfoListDate3(val)
  }
})



  //页面挂载完成
  onMounted( async() => {
    // const result=await reqattrInfoList()

    // console.log('一级分类数据', result);
  categoryStore.reqattrInfoListDate()
    
  })







</script>
